﻿using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

namespace UBlockly
{
    /// <summary>
    /// block资源加载接口
    /// </summary>
    public interface IBlockLoader
    {
        string CustomConfigPath { get; }
        void LoadResource<T>(string assetName, System.Action<T> callback) where T : Object;
    }

    

    public class Ini
    {
        [System.Runtime.InteropServices.DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

        [System.Runtime.InteropServices.DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def,
            System.Text.StringBuilder retVal, int size, string filePath);

        private string sPath = null;

        public Ini(string path)
        {
            sPath = path;
        }

        public void Write(string section, string key, string value)
        {
            WritePrivateProfileString(section, key, value,sPath);
        }

        public string ReadValue(string section, string key)
        {
            //每次从ini读取多少字节
            System.Text.StringBuilder temp = new StringBuilder(255);
            GetPrivateProfileString(section, key, "", temp, 255, sPath);
            return temp.ToString();
        }
    }
}

